
# -*- coding: utf-8 -*-


import unittest
import sys
import os
import time


# 添加执行环境
file_exec_path = os.path.dirname(os.path.dirname(os.path.dirname(__file__)))
sys.path.insert(0, file_exec_path)
from framework_strategy.gopy.trader.engine import StrategyManager, EmailEngine, MainEngine, EventEngine  # NOQA
from framework_strategy.gopy.base.api import API  # NOQA
from framework_strategy.gopy.gateways.object import *  # NOQA
from framework_strategy.gopy.gateways.xt.xt_api import XTGateway  # NOQA
from framework_strategy.gopy.strategy.engine import *  # NOQA


def init_engine():
    event_engine = EventEngine()
    main_engine = MainEngine(event_engine)

    return main_engine, event_engine

class TestStrategy(unittest.TestCase):

    @unittest.skip
    def test_init(self):

        sr = StrategyRegister()
        sr.from_cls_init(*init_engine())
        sl = StrategyLoad(sr)
        # values = sl.load_strategy_class_from_folder()

        sl.start()
        time.sleep(10)
        print(sr.classes)
        sl.stop()
        # print([s for s in values])

    def test_strategy_manager(self):

        sm = StrategyManager(*init_engine())
        time.sleep(2)
        sm.start_all()
        time.sleep(5)
        sm.close()


if __name__ == "__main__":
    unittest.main()
    pass
